package com.qf.collection;

public class Cat extends Animal implements Comparable<Cat>{
    private String name;

    private Integer age;

    public Cat() {
    }

    public Cat(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }


    /**
     * 两只猫如何比较大小呢？
     * 按照猫的年龄比较大小
     * @param o the object to be compared.
     * @return
     */
    @Override
    public int compareTo(Cat o) {
//        return age - o.age;
//        return age.compareTo(o.getAge());
//        return o.age - age;
//        return name.compareTo(o.name);
        return name.length() - o.name.length();
    }
}
